﻿using System.Web.Mvc;

namespace Ams.Mvc.Bootstrap
{
    public static class ViewDataExtensions
    {
        public static bool IsTrue(this ViewDataDictionary viewData, string keyWithBooleanValue)
        {
            return viewData.ContainsKey(keyWithBooleanValue) && (bool) viewData[keyWithBooleanValue];
        }

        public static bool IsTrue<TModel>(this ViewDataDictionary<TModel> viewData, string keyWithBooleanValue)
        {
            return viewData.ContainsKey(keyWithBooleanValue) && (bool) viewData[keyWithBooleanValue];
        }

        public static bool IsTrue(this TempDataDictionary viewData, string keyWithBooleanValue)
        {
            return viewData.ContainsKey(keyWithBooleanValue) && (bool) viewData[keyWithBooleanValue];
        }
    }
}
